import axios from 'axios'
import { Message } from 'element-ui'
const instance = axios.create({
  timeout: 4000

})
instance.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
instance.interceptors.request.use((config) => {

  config.headers.Authorization = sessionStorage.getItem('token')



  return config
}, (error) => {
  return Promise.reject(error)
})

instance.interceptors.response.use((response) => {

  return response.data
}, (error) => {
  if (!error.response) {

    Message.error('网络错误,请稍后重试')
  } else {
    const { status } = error.response
    console.log(error);
  }

})

export default instance